﻿#region Copyright (c) 2011, thinktecture (http://www.thinktecture.com)

/*
   thinktecture.UIAnnotations was developed by Jörg Neumann.
   Copyright (c) 2011, thinktecture (http://www.thinktecture.com).
   All rights reserved, comes as-is and without any warranty. Use of this
   source file is governed by the license which is contained in LICENSE.TXT 
   in the distribution.
*/

#endregion

using System;
using System.Linq;
using System.Collections.ObjectModel;

namespace Thinktecture.DataForm
{
    public sealed class ControlMappingCollection : ObservableCollection<ControlMapping>
    {
        public ControlMapping this[Type dataType]
        {
            get
            {
                return (from mapping in this where mapping.DataType != null && mapping.DataType.Equals(dataType) select mapping).FirstOrDefault();
            }
        }
        public ControlMapping this[string dataPropertyName]
        {
            get
            {
                return (from mapping in this where mapping.DataPropertyName != null && mapping.DataPropertyName.Equals(dataPropertyName) select mapping).FirstOrDefault();
            }
        }
    }
}
